package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.relation.RelationBrandCategoryBO;
import com.micro.modual.model.dto.relation.RelationBrandCategoryListDTO;
import com.micro.modual.service.GoodsBrandCategoryService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020/7/11
 */
@Api(tags = "品牌分类关联")
@RestController
@RequestMapping(value = "/relationBrandCategory")
public class RelationBrandCategoryController {

    @Autowired
    private GoodsBrandCategoryService goodsBrandCategoryService;

    /**
     * <h2>查询品牌分类关联信息-带分页</h2>
     * @param map  请求对象
     * @return
     */
    @GetMapping(value = "/findRelationBrandCategoryPageList")
    public RespJsonPageData<RelationBrandCategoryListDTO> findRelationBrandCategoryPageList(@RequestParam Map<String,Object> map){
        return goodsBrandCategoryService.findRelationBrandCategoryPageList(map);
    }

    /**
     * <h2>查询品牌分类关联信息-无分页</h2>
     * @param map 请求对象
     * @return
     */
    @GetMapping(value = "/findRelationBrandCategoryList")
    public RespJsonData<List<RelationBrandCategoryListDTO>> findRelationBrandCategoryList(@RequestParam Map<String,Object> map){
        return goodsBrandCategoryService.findRelationBrandCategoryList(map);
    }

    /**
     * 新增品牌分类关联
     * @param relationBrandCategoryBO
     * @return
     */
    @PostMapping(value = "/addRelationBrandCategory")
    public RespJson addRelationBrandCategory(@RequestBody RelationBrandCategoryBO relationBrandCategoryBO){
        return goodsBrandCategoryService.addRelationBrandCategory(relationBrandCategoryBO);
    }

    /**
     * 移除品牌分类关联
     * @param id
     * @return
     */
    @PostMapping(value = "/removeRelationBrandCategory/{id}")
    public RespJson removeRelationBrandCategory(@PathVariable("id") Long id){
        return goodsBrandCategoryService.deleteById(id);
    }
}
